<template>
    <div class="differenceDetial">
        <Form ref="formData" :model="formData" :rules="formRules" :label-width="120" >
            <Row>
                <Col>
                    <FormItem label="合同号" prop="contractNo">
                    <Input   v-model="formData.contractNo" disabled   type="text"   placeholder />
                    </FormItem>
                </Col>
                <Col>
                    <FormItem label="手机号" prop="number">
                        <Input  v-model="formData.number"  disabled  type="text"   />
                    </FormItem>
                </Col>

                <Col>
                    <FormItem label="姓名" prop="name">
                        <Input v-model="formData.name"  disabled  type="text"  />
                    </FormItem>
                </Col>
            </Row>
            <div v-if="whetherCustom=='yes'">
            <Row>
                <FormItem   label="短信内容" prop="templateContent">
                <Input v-model="formData.templateContent" type="textarea" class="business-textarea" />
                </FormItem>
            </Row>
            </div>
        </Form>
    </div>
</template>

<script>
    export default {
        name: "sendMessages",
        props: {
            Obj: {
                type: Object
            },
            whetherCustom:{
                type: String
            }
        },
        data() {
            return {
                formData:{
                    contractNo:"",
                    number:"",
                    custName:"",
                    templateContent:"",
                },
                formRules: {
                    templateContent: [
                        {required: true, message: "模板内容必填", trigger: "change"}
                    ],
                },
            }
        },
        mounted() {
            this.init();
        },
        methods: {
            init() {
                this.formData.contractNo = this.Obj.contractNo;
                this.formData.number = this.Obj.phone;
                this.formData.name = this.Obj.custName;
                this.formData.templateType = "short-msg";

            },

            /*
        * formData 数据验证 验证通过后 将数据传回父级处理  (保存/提交/审核 通用)
        * @param {String} funcName 回传给父级的方法 (注意父级需要传方法)
        * @param {Object} [data]   父级带来的数据
        */
            formValidate(funcName,data) {
                if (!funcName) return;
                this.formData.whetherCustom = this.whetherCustom;
                this.$refs.formData.validate(valid => {
                    if (valid) {
                        let d = Object.assign({},data, this.formData);
                        this.$emit(funcName, d);
                    } else {
                        this.$Message.error("验证不通过!");
                        this.$emit("closeSpin");
                        verifyErrorToView(this.$refs.formData.fields);
                    }
                });
            },
        }
    };
</script>
<style scoped lang="less">
    .total {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        flex-flow: row nowrap;
        padding: 16px 0;

        span {
            display: inline-block;
            width: 20%;
            padding-left: 18px;
            padding-right: 18px;
        }
    }

    .business-textarea {
        max-width: 100%;
    }
</style>
